<?php
/*
 * ebiz front
 *
 * Promotion Condition Dao
 *
 * @author fusq
 *
 */

require_once '../app/core/models/BaseDao.php';
require_once '../app/core/db/DBUtil.class.php';

class PromotionConditionDao extends BaseDao {

    private $tableName = "promotion_conditions";

    public function __construct($dbUtil){
    	parent::__construct($dbUtil);
    }

    public function getConditionByType($promotionId,$type){
        $param = array($promotionId,$type);
        $sql = "select * from $this->tableName where promotion_id = ? and promotion_condition_type = ? and is_delete = 0 ";
        return $this->dbUtil->SelectData($sql,$param);
    }

    public function getConditionBypromotionid($promotionId){
        $param = array($promotionId);
        $sql = "select * from $this->tableName where promotion_id = ? and is_delete = 0 ";
        return $this->dbUtil->SelectData($sql,$param);
    }
    
    public function saveExchangePromotionConditionInfo($param){
    	$sql = "insert into $this->tableName 
    	(promotion_id, promotion_condition_type, condition_value, code_value, modified, created) 
    	values (?,?,?,?,now(),now())";
        return $this->dbUtil->ExecuteQuery($sql, $param);
    }
    
}